package factory;

interface Prodect {
    void produce();
}

class ProductA implements Prodect {

    @Override
    public void produce() {
        System.out.println("---------------product A---------------");
    }
}
class ProductB implements Prodect {

    @Override
    public void produce() {
        System.out.println("---------------product B---------------");
    }
}

class Factory {
    public Prodect createProduct(String type) {
        if (type.equals("A")) {
            return new ProductA();
        } else if (type.equals("B")) {
            return new ProductB();
        } else {
            return null;
        }
    }
}

public class Client {
    public static void main(String[] args) {
        Factory factory = new Factory();
        Prodect productA = factory.createProduct("A");
        Prodect productB = factory.createProduct("B");
        productA.produce();
        productB.produce();
    }
}
